Repository navigation
feat(uploads): report PDFs and covers go straight to R2 - #1699
Conversation
The browser asks Convex for signed addresses (files/uploads:start) and sends a file straight to the uploads bucket, in 64 MB parts when it is larger, so no upload goes through our proxy, which takes at most 100 MB a request on dev. files/uploads:finish checks R2 holds all of it. A file is its sender's to hand to a report for an hour; one nothing takes is swept away after a day, as is an upload never finished. A report's PDF, the one its author uploaded beside a PDF with the byline page, its text and its cover are kept in R2. Report fields take a file in R2 or, until migrations/reportFilesToR2 has run, one still in Convex storage. A file in R2 is never handed out by its own address: /reports/open and /reports/file check who may have it each time and send them on to an address signed for 15 minutes. Part of #1695.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 955b77b1f0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…d by the address it came by, and nothing is left in R2 that no row names - A file sent with one PUT is copied, once checked, to a key no address was signed for; the copy it was sent as is deleted. Files sent in parts need no copy: once joined, their addresses write to nothing. - A report's file is served as a PDF or a JPEG whatever it was sent as. - A deleted file's row stays, dropping, until R2 has let its bytes go; the sweep tries a failed delete again. - A file the server makes gets its row before its bytes, and nothing holds it until the function it was made for takes it, so one whose maker failed is swept too. - Kept files nothing took are swept by when they arrived, not when they were started. - The migration copies in Node, which holds a 100 MB PDF, and a report's text claim is deleted with it.
…it said; only a file it doesn't hold reads as gone
Our Convex address sits behind Cloudflare's proxy, which takes at most 100 MB a request on dev. Supplements and larger reports need Zenodo's limit, 50 GB. This first part moves the report PDF and its cover picture to R2. Extraction, screening, community settings and assistant uploads follow in the next pull requests. Part of #1695.
How an upload goes now
files/uploads:startfor signed addresses. A file up to 64 MB gets one address. A larger one gets an R2 upload in parts, one address per 64 MB part.UPLOADS_*bucket (openscholar-uploads-devon dev), 4 parts at a time and 3 tries a part (lib/files/upload.ts).files/uploads:finishis only the sender's. It joins the parts and refuses unless R2 holds exactly the size declared.Reports
migrations/reportFilesToR2has run, one still in Convex storage. Every reader handles both./reports/open(files out for everyone) and/reports/file(the workspace and reviewers) check who may have it each time, then redirect to an address signed for 15 minutes. The app's routes follow that redirect as before, ranges included.Checks
npx tsc --noEmit,check:user-actions,check:convex-rules,check:ui-rulesnpx vitest run convex/reports convex/files convex/migrations: all pass, including new tests for the upload boundary, the sweep and the migrationstartsigns in Convex's own runtimehttp://localhost:3685passes CORSfinishrefuses a file that hasn't arrived and accepts it once it hasAfter merge
npx convex run migrations/reportFilesToR2:run '{"dryRun":true}', then withfalse.openscholar-uploads-prod) with CORS for discover.openscholar.ai, a token scoped to it, and the fourUPLOADS_*settings. Then run the same migration.